home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Games / Doom / ADoom-0.8 / ADoom_src / i_system.c < prev    next >
C/C++ Source or Header  |  1998-06-24  |  3KB  |  184 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //
  21. //-----------------------------------------------------------------------------
  22.  
  23. static const char
  24. rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
  25.  
  26.  
  27. #include <stdlib.h>
  28. #include <stdio.h>
  29. #include <string.h>
  30.  
  31. #include <stdarg.h>
  32. #include <sys/time.h>
  33. #include <unistd.h>
  34.  
  35. #include "doomdef.h"
  36. #include "m_misc.h"
  37. #include "i_video.h"
  38. #include "i_sound.h"
  39.  
  40. #include "d_net.h"
  41. #include "g_game.h"
  42.  
  43. #ifdef __GNUG__
  44. #pragma implementation "i_system.h"
  45. #endif
  46. #include "i_system.h"
  47.  
  48.  
  49.  
  50.  
  51. int    mb_used = 6;
  52.  
  53.  
  54. void
  55. I_Tactile
  56. ( int    on,
  57.   int    off,
  58.   int    total )
  59. {
  60.   // UNUSED.
  61.   on = off = total = 0;
  62. }
  63.  
  64. ticcmd_t    emptycmd;
  65. ticcmd_t*    I_BaseTiccmd(void)
  66. {
  67.     return &emptycmd;
  68. }
  69.  
  70.  
  71. int  I_GetHeapSize (void)
  72. {
  73.     return mb_used*1024*1024;
  74. }
  75.  
  76. byte* I_ZoneBase (int*    size)
  77. {
  78.     *size = mb_used*1024*1024;
  79.     return (byte *) malloc (*size);
  80. }
  81.  
  82.  
  83.  
  84. //
  85. // I_GetTime
  86. // returns time in 1/70th second tics
  87. //
  88. int  I_GetTime (void)
  89. {
  90.     struct timeval    tp;
  91.     struct timezone    tzp;
  92.     int            newtics;
  93.     static int        basetime=0;
  94.   
  95.     gettimeofday(&tp, &tzp);
  96.     if (!basetime)
  97.     basetime = tp.tv_sec;
  98.     newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
  99.     return newtics;
  100. }
  101.  
  102.  
  103.  
  104. //
  105. // I_Init
  106. //
  107. void I_Init (void)
  108. {
  109.     I_InitSound();
  110.     //  I_InitGraphics();
  111. }
  112.  
  113. //
  114. // I_Quit
  115. //
  116. void I_Quit (void)
  117. {
  118.     D_QuitNetGame ();
  119.     I_ShutdownSound();
  120.     I_ShutdownMusic();
  121.     M_SaveDefaults ();
  122.     I_ShutdownGraphics();
  123.     exit(0);
  124. }
  125.  
  126. void I_WaitVBL(int count)
  127. {
  128. #ifdef SGI
  129.     sginap(1);                                           
  130. #else
  131. #ifdef SUN
  132.     sleep(0);
  133. #else
  134.     usleep (count * (1000000/70) );                                
  135. #endif
  136. #endif
  137. }
  138.  
  139. void I_BeginRead(void)
  140. {
  141. }
  142.  
  143. void I_EndRead(void)
  144. {
  145. }
  146.  
  147. byte*    I_AllocLow(int length)
  148. {
  149.     byte*    mem;
  150.         
  151.     mem = (byte *)malloc (length);
  152.     memset (mem,0,length);
  153.     return mem;
  154. }
  155.  
  156.  
  157. //
  158. // I_Error
  159. //
  160. extern boolean demorecording;
  161.  
  162. void I_Error (char *error, ...)
  163. {
  164.     va_list    argptr;
  165.  
  166.     // Message first.
  167.     va_start (argptr,error);
  168.     fprintf (stderr, "Error: ");
  169.     vfprintf (stderr,error,argptr);
  170.     fprintf (stderr, "\n");
  171.     va_end (argptr);
  172.  
  173.     fflush( stderr );
  174.  
  175.     // Shutdown. Here might be other errors.
  176.     if (demorecording)
  177.     G_CheckDemoStatus();
  178.  
  179.     D_QuitNetGame ();
  180.     I_ShutdownGraphics();
  181.     
  182.     exit(-1);
  183. }
  184.